<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>m_to_m_transform (relation_transform.rb)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File relation_transform.rb, line 35</span>
 <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">m_to_m_transform</span>(<span class="ruby-identifier">row_details</span>,<span class="ruby-identifier">new_connection</span>)
        <span class="ruby-comment cmt">#The first table details are being extracted from the config file. </span>
        <span class="ruby-identifier">first_table</span> = <span class="ruby-identifier">row_details</span>[<span class="ruby-value">1</span>]
        <span class="ruby-identifier">first_table_primary_key</span> = <span class="ruby-identifier">row_details</span>[<span class="ruby-value">2</span>]
        <span class="ruby-identifier">first_row_specs</span> = <span class="ruby-identifier">first_handle_primary_key</span>(<span class="ruby-identifier">first_table_primary_key</span>,<span class="ruby-identifier">first_table</span>,<span class="ruby-identifier">new_connection</span>)
        <span class="ruby-comment cmt">#The second table details are being extracted from the config file.</span>
        <span class="ruby-identifier">second_table</span> = <span class="ruby-identifier">row_details</span>[<span class="ruby-value">3</span>]
        <span class="ruby-identifier">second_table_primary_key</span> = <span class="ruby-identifier">row_details</span>[<span class="ruby-value">4</span>]
        <span class="ruby-identifier">second_row_specs</span> = <span class="ruby-identifier">handle_primary_key</span>(<span class="ruby-identifier">second_table_primary_key</span>,<span class="ruby-identifier">second_table</span>,<span class="ruby-identifier">new_connection</span>)
        <span class="ruby-comment cmt">#The sql commands to create the third tabke and the primary keys.</span>
        <span class="ruby-identifier">new_connection</span>.<span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;ALTER TABLE #{first_table} ADD PRIMARY KEY (#{first_table_primary_key})&quot;</span>)
        <span class="ruby-identifier">new_connection</span>.<span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;ALTER TABLE #{second_table} ADD PRIMARY KEY (#{second_table_primary_key})&quot;</span>)
        <span class="ruby-identifier">new_connection</span>.<span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;CREATE TABLE #{first_table}_#{second_table} (#{first_table}_#{first_table_primary_key} #{first_row_specs},#{second_table}_#{second_table_primary_key} #{second_row_specs})&quot;</span>)
        <span class="ruby-identifier">new_connection</span>.<span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;ALTER TABLE #{first_table}_#{second_table} ADD PRIMARY KEY (#{first_table}_#{first_table_primary_key},#{second_table}_#{second_table_primary_key})&quot;</span>)
 <span class="ruby-keyword kw">end</span></pre>
</body>
</html>